/* eslint-disable @typescript-eslint/no-explicit-any */

//日期格式化
export const formatDate = (str: any) => {
    const sr = str ? new Date(str) : new Date()
    const year = sr.getFullYear()
    const mon = sr.getMonth() + 1
    const date = sr.getDate()
    const hour = sr.getHours()
    const min = sr.getMinutes()
    const sec = sr.getSeconds()
    //补零
    const bl = (num: any) => {
        return num < 10 ? `0${num}` : num
    }
    const res = `${year}-${bl(mon)}-${bl(date)} ${bl(hour)}:${bl(min)}:${bl(sec)}`
    return res
}